﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.AspNet.SignalR;
using Microsoft.AspNet.SignalR.Hubs;
using Leikjavefurinn.Repo;
using Leikjavefurinn.Context;

namespace Leikjavefurinn.Controllers
{
    public class TTTGameHub : Hub
    {
        public void Join(string groupId)
        {
            //Context.User.Identity.Name
            //Context.QueryString
            Groups.Add(Context.ConnectionId, groupId);
        }

        public void ClickCell(string groupName, string cellId)
        {
            Clients.OthersInGroup(groupName).cellClicked(cellId);
        }

        public bool GameIsActive()
        {
            return true;
        }

        //Kallar á SetWinner fallið
        public void SetWinner(string gameID, Guid userID)
        {
            TicTacToeRepo tttRepo = new TicTacToeRepo();
            tttRepo.SetWinnerID(userID);
        }

        public bool IsFull()
        {
            return true;
        }
    }
}